package group

import (
	"gddgame.cc/galaxy/common/dsl/game"
	"gddgame.cc/galaxy/utils"
)

//go:generate msgp

//msgp:tuple RelationGroup
type RelationGroup struct {
	Id  int    `json:"id" msg:"id"`
	Key string `json:"string" msg:"string"`

	*game.DataExtend `json:"-" msg:"-"`
}

func NewRelationGroup(provider *game.DataProvider, relationGroup *SettingRelationGroup) *RelationGroup {
	extend := game.NewDataExtend(utils.ToString(relationGroup.Id), relationGroup.UpdateTime).Add("name", relationGroup.Name)
	lang := &RelationGroup{
		Id:  relationGroup.Id,
		Key: relationGroup.Key,

		DataExtend: extend,
	}
	return lang
}

//msgp:tuple RelationGroupManager
type RelationGroupManager struct {
	Id   int    `json:"id" msg:"id"`
	Key  string `json:"key" msg:"key"`
	Name string `json:"name" msg:"name"`

	*game.DataExtend `json:"-" msg:"-"`
}

func NewRelationGroupManager(provider *game.DataProvider, relationGroup *SettingRelationGroup) *RelationGroupManager {
	extend := game.NewDataExtend(utils.ToString(relationGroup.Id), relationGroup.UpdateTime)
	lang := &RelationGroupManager{
		Id:   relationGroup.Id,
		Key:  relationGroup.Key,
		Name: relationGroup.Name[game.DefaultLanguage],

		DataExtend: extend,
	}
	return lang
}
